package cn.com.srest.common.bean;
/**
 * SRest请求返回JSON字符串的一般形式
 * 成功！
 * {"meta":{"success":true,"message":"ok"},
 *  "data":{...}
 * }
 * 失败！
 * {"meta":{"success":false,"message":"error"}
 * }
 * @author Liw
 *
 */
public class Response {
	private static final String OK = "ok";
	private static final String ERROR = "error";
	private Meta meta ;
	private Object date ;
	public Response success(){
		Meta meta = new Meta(true,OK);
		this.meta = meta ;
		return this ;
	}
	public Response success(Object object){
		Meta meta = new Meta(true,OK);
		this.setMeta(meta);
		this.setDate(object);
		return this ;
	}
	public Response failure(){
		Meta meta = new Meta(false,ERROR);
		this.setMeta(meta);
		return this ;
	}
	public Response failure(String message){
		Meta meta = new Meta(false,message);
		this.setMeta(meta);
		return this ;
	}
	public Meta getMeta() {
		return meta;
	}
	public void setMeta(Meta meta) {
		this.meta = meta;
	}
	public Object getDate() {
		return date;
	}
	public void setDate(Object date) {
		this.date = date;
	}
}
